package com.example.mybaseapp.ui.jetpack

import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.lifecycle.ViewModelProvider
import com.example.lib_base.BaseActivity
import com.example.mybaseapp.R
import com.example.mybaseapp.databinding.ActivityViewModelBinding
import kotlin.random.Random

class ViewModelActivity : BaseActivity<ActivityViewModelBinding>() {
    private lateinit var  viewModelData:ViewModelData
    private var content = 1
    override fun onViewInit() {
        viewModelData = ViewModelProvider(this)[ViewModelData::class.java]

        viewModelData.txShowContent.observe(this){
            binding.txShow.text = it
        }

        binding.btnChange.setOnClickListener {
            content = Random.nextInt(100)
//                content = Math.random().toInt()
            viewModelData.txShowContent.value = content.toString()
            binding.txContent.text = content.toString()
        }
    }
}